Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jun 19, 2025

Description

This PR adds the "Claude Code" provider, adding support for using Claude models through a locally installed command-line tool so users can take advantage of their Claude Code Pro and Max subscriptions within Roo Code

Changes Made

  • Added new "Claude Code" provider that executes the local claude CLI tool
  • Implemented streaming support for CLI JSON output parsing
  • Created configuration UI for setting the CLI tool path
  • Added all necessary type definitions and model configurations
  • Included English translations for the new provider
  • Moved ApiHandlerOptions type to the shared types package for proper module boundaries

Technical Details

New Files

  • packages/types/src/providers/claude-code.ts - Model definitions for Claude Code
  • src/api/providers/claude-code.ts - Main handler implementation
  • src/integrations/claude-code/run.ts - CLI execution logic using execa
  • src/integrations/claude-code/types.ts - Response type definitions
  • webview-ui/src/components/settings/providers/ClaudeCode.tsx - Settings UI component

Modified Files

  • Updated provider settings schemas to include claudeCodePath configuration
  • Added Claude Code to provider selection UI
  • Updated localization files with new strings
  • Refactored type imports to maintain proper module boundaries

Testing

  • All existing tests pass (2325 tests)
  • TypeScript compilation successful
  • No linting errors
  • Build process completes without errors

How to Use

  1. Install the Claude CLI tool locally
  2. Select "Claude Code" from the API provider dropdown
  3. Configure the path to the claude executable (or leave blank to use PATH)
  4. The provider will execute the CLI tool and stream responses

Notes

This PR ports the "Claude Code" provider from an external pull request (cline/cline PR #4111), adding support for using Claude models through a locally installed command-line tool.

  • This provider requires users to have the Claude CLI tool installed separately
  • The CLI tool path can be configured in settings or left blank to use the system PATH
  • All Claude models supported by the CLI tool are available through this provider

Important

Adds Claude Code provider for local CLI integration, including model definitions, handler implementation, CLI execution logic, and UI configuration.

  • Behavior:
    • Adds "Claude Code" provider for local CLI tool execution.
    • Implements streaming support for CLI JSON output parsing.
    • Adds configuration UI for CLI tool path.
    • Supports all Claude models available via CLI.
  • Files:
    • claude-code.ts: Model definitions.
    • claude-code.ts: Main handler implementation.
    • run.ts: CLI execution logic using execa.
  • UI:
    • Adds ClaudeCode.tsx for settings UI component.
    • Updates provider selection UI and localization files.
  • Types:
    • Moves ApiHandlerOptions to shared types package.

This description was created by Ellipsis for c32f71c. You can customize this summary. It will automatically update as commits are pushed.

Copilot AI review requested due to automatic review settings June 19, 2025 02:21
@hannesrudolph hannesrudolph requested review from cte, jr and mrubens as code owners June 19, 2025 02:21
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates support for the Claude Code provider via a locally installed CLI tool, extending both the backend API and the settings UI.

  • Introduces new provider-specific files for handling CLI execution and streaming responses.
  • Updates UI components and provider settings to include configuration for the Claude Code CLI tool.
  • Refactors type definitions and API handler resolution to support the new provider.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
webview-ui/src/components/settings/providers/index.ts Exports the new ClaudeCode settings component.
webview-ui/src/components/settings/providers/ClaudeCode.tsx Adds the UI component for configuring the Claude Code CLI path.
webview-ui/src/components/settings/constants.ts Updates provider models and provider list to include Claude Code.
webview-ui/src/components/settings/ApiOptions.tsx Integrates the new Claude Code option in the provider selection UI.
src/shared/api.ts Refactors ApiHandlerOptions type import for consistency.
src/integrations/claude-code/types.ts Adds type definitions for messages from the Claude Code CLI integration.
src/integrations/claude-code/run.ts Implements CLI execution logic for the Claude Code provider.
src/api/transform/stream.ts Extends stream types to include error chunk handling.
src/api/retry.ts Incorporates retry logic for API calls with error handling.
src/api/providers/index.ts Exports the new ClaudeCodeHandler for API provider resolution.
src/api/providers/claude-code.ts Implements the Claude Code API handler with streaming support.
src/api/index.ts Updates handler construction to include the Claude Code provider.
packages/types/src/providers/index.ts Exports new provider types including Claude Code.
packages/types/src/providers/claude-code.ts Defines type information and default model IDs for Claude Code.
packages/types/src/provider-settings.ts Extends provider settings schemas to include Claude Code configuration.
packages/types/src/api.ts Updates ApiHandlerOptions definition for new provider support.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 19, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 19, 2025
@hannesrudolph
Copy link
Collaborator Author

✅ Fixed the knip CI failure by removing the unused src/api/retry.ts file. The CI checks are now running.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 19, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 19, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 20, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 20, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Review] to PR [Changes Requested] in Roo Code Roadmap Jun 20, 2025
hannesrudolph and others added 8 commits June 20, 2025 18:03
- Use cost_usd from CLI response when available
- Fall back to calculating cost based on token usage and model pricing
- Ensures consistent cost reporting across all providers
- Only use cost_usd from CLI response when provided
- Default to 0 when CLI doesn't provide cost (e.g., subscription users)
- Don't calculate cost based on token usage as it may not apply to all users
@daniel-lxs daniel-lxs force-pushed the feat/claude-code-provider branch from 5770341 to 7dd9357 Compare June 20, 2025 23:14
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Review] in Roo Code Roadmap Jun 22, 2025
- Added processExitedWithError translation key to all supported languages
- This replaces concatenated translation calls with a single unified key
- Allows for more natural word order in non-English languages
- Addresses review feedback from PR #4864
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned this up a bit, it had some changes to the types that were unnecessary.

@mrubens mrubens merged commit ff9b6b3 into main Jun 23, 2025
7 checks passed
@mrubens mrubens deleted the feat/claude-code-provider branch June 23, 2025 03:17
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 23, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 23, 2025
cte pushed a commit that referenced this pull request Jun 24, 2025
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Daniel <[email protected]>
Co-authored-by: Daniel Riccio <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
@sahksas sahksas mentioned this pull request Jun 26, 2025
23 tasks
Alorse pushed a commit to Alorse/Roo-Code that referenced this pull request Jun 27, 2025
…4864)

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Daniel <[email protected]>
Co-authored-by: Daniel Riccio <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
Alorse pushed a commit to Alorse/Roo-Code that referenced this pull request Jun 27, 2025
…4864)

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Daniel <[email protected]>
Co-authored-by: Daniel Riccio <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants